// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Subsystems/GameInstanceSubsystem.h"
#include "../StructAndEnum/StructAndEnum.h"
#include "MySQLSubsystem.generated.h"

/**
 * 
 */



UCLASS()
class SGAME_API UMySQLSubsystem : public UGameInstanceSubsystem
{
	GENERATED_BODY()
public:

	//开始执行
	virtual void Initialize(FSubsystemCollectionBase& Collection) override;

	//结束执行
	virtual void Deinitialize() override;

	//需要创建子系统
	virtual bool ShouldCreateSubsystem(UObject* Outer) const override { return true; }

	//测试函数
	UFUNCTION(BlueprintCallable)
		void MySubsystemTest();

	//链接数据库
	UFUNCTION(BlueprintCallable)
		void JoinDB();

	//查询玩家是否可以登录
	UFUNCTION(BlueprintCallable)
		FLoginMessage LoginDetection(FLoginMessage Message);

	//查询玩家是否可以注册此账号
	UFUNCTION(BlueprintCallable)
		bool CanRegisterPlayerName(FString Message);

	//注册账号
	UFUNCTION(BlueprintCallable)
		void RegisterAccount(FLoginMessage Message);

	//查询玩家是否进入准备关卡
	UFUNCTION(BlueprintCallable)
		bool IsPlayerHaveReadyInfo(int32 PlayerID);

	//玩家准备信息入库
	UFUNCTION(BlueprintCallable)
		void WarehousingReadyInfo(FReadyInfo Message);
	//查询玩家信息
	UFUNCTION(BlueprintCallable)
		FReadyInfo QueryPlayerInfoFromDB(int32 PlayerID);




	//查询语句
	//"SELECT logindb.playerid,logindb.username,logindb.password FROM logindb WHERE "root" = logindb.username AND "adin1234" = logindb.password";
	
};
